Skip to content

Commit

Permalink
chap-05: Reindex older demos
Browse files Browse the repository at this point in the history
Signed-off-by: Razvan Deaconescu <[email protected]>
  • Loading branch information
razvand authored and gabrielmocanu committed Mar 30, 2024
1 parent 9e1e777 commit 297b2bf
Show file tree
Hide file tree
Showing 18 changed files with 103 additions and 0 deletions.
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions curs/chap-05-ihs/05-hello-world/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# chap-03-demo

1. Demo gdb
- make
- gdb hello
- Comands: b main, r, n
- set $eax = 0xffffffff
- set $eip = main

2. Demo gdb
step through hello.asm to inspect the changes to the following registers:
* EAX, AX, AH, AL
* EFLAGS
* EIP
Note: Instructions to whatch are: MOV, ADD, JMP

3. Demo Inspect ~/.gdbinit

Check failure on line 17 in curs/chap-05-ihs/05-hello-world/README.md

View workflow job for this annotation

GitHub Actions / checkpatch review

ERROR: trailing whitespace
- less ~/.gdbinit

cleanup:
set disassembly-flavor intel
set history save on



File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
78 changes: 78 additions & 0 deletions curs/chap-05-ihs/06-dandamudi/ijump.sasm.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
;; adaptat cu macrourile SASM - ușor diferite !
;Sample indirect jump example IJUMP.ASM
;
; Objective: To demonstrate the use of indirect jump.
; Input: Requests a digit character from the user.
; Output: Appropriate class selection message.
%include "io.inc"

section .data
jump_table dd code_for_0 ; indirect jump pointer table
dd code_for_1
dd code_for_2
dd default_code ; default code for digits 3-9
dd default_code
dd default_code
dd default_code
dd default_code
dd default_code
dd default_code

prompt_msg db "Type a digit: ",0
msg_0 db "Economy class selected.",0
msg_1 db "Business class selected.",0
msg_2 db "First class selected.",0
msg_default db "Not a valid code!",0
msg_nodigit db "Not a digit! Try again.",0
key db 0

section .text
global main
main:
mov ebp, esp; for correct debugging
read_again:
PRINT_STRING prompt_msg ; request a digit
sub EAX,EAX ; EAX = 0
GET_CHAR key
mov AL, [key] ; read input digit and
cmp AL,'0' ; check to see if it is a digit
jb not_digit
cmp AL,'9'
ja not_digit
; if digit, proceed
sub AL,'0' ; convert to numeric equivalent
mov ESI,EAX ; ESI is index into jump table
add ESI,ESI ; ESI = ESI * 4
add ESI,ESI
jmp [jump_table+ESI] ; indirect jump based on ESI
test_termination:
cmp AL,2
ja done
jmp read_again
code_for_0:
PRINT_STRING msg_0
NEWLINE
jmp test_termination
code_for_1:
PRINT_STRING msg_1
NEWLINE
jmp test_termination
code_for_2:
PRINT_STRING msg_2
NEWLINE
jmp test_termination
default_code:
PRINT_STRING msg_default
NEWLINE
jmp test_termination

not_digit:
PRINT_STRING msg_nodigit
NEWLINE
jmp read_again
done:
mov eax, 1
mov ebx, 0
int 0x80 ; exit(0)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 297b2bf

Please sign in to comment.