Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3 - jump opcode causes a problem #256

Open
h-enes-simsek opened this issue Dec 11, 2022 · 0 comments
Open

3 - jump opcode causes a problem #256

h-enes-simsek opened this issue Dec 11, 2022 · 0 comments

Comments

@h-enes-simsek
Copy link

In lecture 3 there is a problem due to the different outputs of the jump instruction.

This is asm code

;
; A simple boot sector program that demonstrates addressing.
;

mov ah , 0x0e ; int 10/ ah = 0eh -> scrolling teletype BIOS routine

; First attempt
mov al , the_secret
int 0x10 ; Does this print an X? no

; Second attempt
mov al , [the_secret]
int 0x10 ; Does this print an X? no

; Third attempt
mov bx , the_secret
add bx , 0x7c00
mov al , [bx]
int 0x10 ; Does this print an X?

; Fourth attempt
mov al , [0x7c1e]
int 0x10 ; Does this print an X?

jmp $ ; Jump forever. 
the_secret :
  db "X"

; Padding and magic BIOS number.
times 510 -( $ - $$ ) db 0
dw 0xaa55

Binary output according to the book

b4 0 e b0 1e cd 10 a0 1e 00 cd 10 bb 1e 00 81 c3
00 7 c 8a 07 cd 10 a0 1e 7c cd 10 e9 fd ff 58 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
***
00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa

Binary output in my computer (Win10-NASM)

B4 0E B0 1D CD 10 A0 1D 00 CD 10 BB 1D 00 81 C3 
00 7C 8A 07 CD 10 A0 1E 7C CD 10 EB FE 58 00 00 
***
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA

First jump code: e9 fd ff
Second jumo code: EB FE

So the address of the 'X' is different because of the jump opcode. But we added 0x1e hardcoded offset.
And this leads that 'the fourth attempt is not working. I don't know what causes this but the compiler can choose different options of course. A little reminder could be added not to waste people's time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant